<template>
  <div style="width: 100%">
    <div id="deawer">
      <v-tableTitle :btnConfig="btnConfig"
                    @cancel="cancel"
                    @save="save"></v-tableTitle>
      <div class="detailBox">
        <v-detail ref="detail"></v-detail>
      </div>
    </div>
  </div>

</template>

<script>
import baseMixin from "@/mixins/BaseMixin";
import config from "../Config"
import skipMixin from "@/mixins/SkipMixin";
import detail from "../details/Detail"
import tableTitle from "@/components/commons/TableTitle";
import DeawerVue from '../../../bill/costcode/deawer/Deawer.vue';

export default {
  name: "",
  mixins: [baseMixin, config, skipMixin],
  data () {
    return {
      dialogTableVisible: false,
      poUrl: "queryListOfPoModal/true/1/true/true/",
      lookUrl: "queryListOfTaskDetailModal/",
      routeData: {},

    };
  },
  computed: {
    btnConfig () {
      return [
        { label: this.$t('common.save'), certigier: !this.btnPermNameList.includes('WM031306'), invalid: "save" },
        { label: this.$t('common.cancel'), certigier: !this.btnPermNameList.includes('WM031307'), invalid: "cancel" },
      ]
    },
  },
  created () {
  },
  methods: {
    //保存按钮
    save () {
      let self = this;
      let detail = {
        dateId: sessionStorage.getItem('dateId'),
        ...self.$refs.detail.detailData
      };
      self.$refs.detail.$children[1].$refs.input.$refs["from"].validate((valid) => {
        if (valid) {
          self.$api.post(`/PartsLibraryScreen/insertPartsLs`, detail).then(res => {
            
              self.$message.success(res.returnMgr)
              self.cancel();
          })
        }
      })
    },
    //弹框取消
    cancel () {
      this.$router.push({ name: "ljkwBatchSetting" });
    },
  },
  mounted () {
    if (this.$store.state.closeFlag) {
      sessionStorage.setItem('dateId', (new Date()).valueOf())
      this.$store.commit("setCloseFlag", false)
    }
  },
  watch: {},
  components: {
    "v-tableTitle": tableTitle,
    "v-detail": detail,
  },

}
</script>

<style scoped>
</style>
